﻿using System;
using System.Collections.Generic;
using System.Text;
using HAVNet.Core;
using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTAccessorNormals : List<ASTAccessorNormal>
    {
        public override string ToString ()
        {
            return Strings.joinobjs (Environment.NewLine, this);
        }
    }

    public class ASTAccessorNormal : ASTNode
    {
        protected ASTAttributeGroups _attrGroups = null;

        public long modifiers       { get; set; }
        public ASTAttributeGroups   attrGroups  { get { if (null == _attrGroups) _attrGroups = new ASTAttributeGroups(); return _attrGroups; } }
        public ASTBlock             block       { get; set; }
    }

    public class ASTAccessorNormalGet : ASTAccessorNormal
    {
        public override string ToString()
        {
            //  accessorsPossib1Mod = privateMod,
            //  accessorsPossib2Mod = protectedMod|internalMod,
            string sMods = "";

            if (Mods.has(modifiers, Mods.privateMod     ))  sMods += "private ";
            if (Mods.has(modifiers, Mods.protectedMod   ))  sMods += "protected ";
            if (Mods.has(modifiers, Mods.internalMod    ))  sMods += "internal ";

            return
                Lazy.toStringNN(_attrGroups, "", Environment.NewLine) +
                sMods +
                "get" + Environment.NewLine +
                Lazy.toStringNN(block, ";");
        }
    }

    public class ASTAccessorNormalSet : ASTAccessorNormal
    {
        public override string ToString()
        {
            //  accessorsPossib1Mod = privateMod,
            //  accessorsPossib2Mod = protectedMod|internalMod,
            string sMods = "";

            if (Mods.has(modifiers, Mods.privateMod     )) sMods += "private ";
            if (Mods.has(modifiers, Mods.protectedMod   )) sMods += "protected ";
            if (Mods.has(modifiers, Mods.internalMod    )) sMods += "internal ";

            return
                Lazy.toStringNN (_attrGroups, "", Environment.NewLine) +
                sMods +
                "set" + Environment.NewLine +
                Lazy.toStringNN(block, ";");
        }
    }
}
